package Functii.Trigonometrice;
import Functii.*;
import Operator.*;

public class Arcsin extends Functie{

	public static double calcul(double aux1){
		return Math.asin(aux1);
	}
	
	public double calcul(){
		if (getfStang() == null)
			System.exit(1);
		return calcul(getfStang().calcul());
	}
	
	public String derivare(){
	if (getfStang() == null)
		System.exit(1);
	return Cat.concatTermens(getfStang().derivare(),"sqrt(1-" + getfStang().toString() + "^2)");
	}
	public double calculDerivata(){
		if (getfStang() == null)
			System.exit(1);
		return Cat.Calcul(getfStang().calculDerivata(), Math.sqrt(1 - Math.pow(getfStang().calcul(), 2)));
	}
	public String toString(){
		if (getfStang() == null)
			System.exit(1);
		return concatTermeni(getfStang().toString());
	}
	public static String concatTermens(String aux1){
		String aux;
		int nrP;
		nrP = aux1.charAt(0) == '(' ? 0 : 2;
		aux = "arcsin";
		if (nrP != 0) aux += "(";
		aux += aux1;
		if (nrP != 0) aux += ")";
		return aux;
	}
	public String concatTermeni(String aux1){
		String aux;
		int nrP;
		nrP = aux1.charAt(0) == '(' ? 0 : 2;
		aux = "arcsin";
		if (nrP != 0) aux += "(";
		aux += aux1;
		if (nrP != 0) aux += ")";
		return aux;
	}
	public double calculeazaValoare() {
		return this.calcul();
	}
}
